package lanou3g.com.Fragment;


import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * Created by dllo on 2015/10/27.
 */
public class Welcome_Fragment extends Fragment {
    private static final String ARGS_POSITION = "position";
    private static SparseArray<Fragment> fragmentSparseArray = new SparseArray<>();

    public static Fragment newInstance(int position) {
        Fragment f = fragmentSparseArray.get(position);
        if ((f == null)) {
            switch (position) {
                case 0:
                    f = new Welcome_one_Fragment();
                    Bundle bundle_jokes = new Bundle();
                    bundle_jokes.putInt("position", position);
                    f.setArguments(bundle_jokes);
                    break;
                case 1:
                    f = new Welcome_one_Fragment();
                    Bundle bundle_function = new Bundle();
                    bundle_function.putInt("position", position);
                    f.setArguments(bundle_function);
                case 2:
                    f = new Welcome_one_Fragment();
                    Bundle build_function1 = new Bundle();
                    build_function1.putInt("position", position);
                    f.setArguments(build_function1);
                    break;
            }

            fragmentSparseArray.put(position,f);
        }
        return f;
    }
    private Context context;
    private ImageView imageView;
    private int position;

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        this.context = context;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle args = getArguments();
        position = args.getInt(ARGS_POSITION);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return new TextView(context);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
    }

}
